The present disclosure relates to uniformly collecting leaf node sample data throughout an index tree of a database.
Database query optimizers typically require statistics in order to produce optimal query plans. Index statistics may include a number of keys, a number of unique keys, a number of hierarchical levels in an index tree, etc. These statistics are normally gathered by traversing the entire index tree and is a resource-intensive operation and requires substantial I/O bandwidth, especially for large index trees. Users often avoid gathering statistics in a timely manner because of the impact to the system performance while calculating the statistics, thus leading to sub-optimal query plans.